package com.ruoyi.web.controller.snmp;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SnmpArp;
import com.ruoyi.system.service.ISnmpArpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 *  Controller
 *
 * @author ruoyi
 * @date 2025-02-05
 */
@RestController
@RequestMapping("/snmp/arp")
public class SnmpArpController extends BaseController
{
    @Autowired
    private ISnmpArpService snmpArpService;

    /**
     * 查询 列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:arp:list')")
    @GetMapping("/list")
    public TableDataInfo list(SnmpArp snmpArp)
    {
        startPage();
        List<SnmpArp> list = snmpArpService.selectSnmpArpList(snmpArp);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:arp:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SnmpArp snmpArp)
    {
        List<SnmpArp> list = snmpArpService.selectSnmpArpList(snmpArp);
        ExcelUtil<SnmpArp> util = new ExcelUtil<SnmpArp>(SnmpArp.class);
        util.exportExcel(response, list, " 数据");
    }

    /**
     * 获取 详细信息
     */
    @PreAuthorize("@ss.hasPermi('snmp:arp:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(snmpArpService.selectSnmpArpById(id));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('snmp:arp:add')")
    @Log(title = " ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SnmpArp snmpArp)
    {
        return toAjax(snmpArpService.insertSnmpArp(snmpArp));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('snmp:arp:edit')")
    @Log(title = " ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SnmpArp snmpArp)
    {
        return toAjax(snmpArpService.updateSnmpArp(snmpArp));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('snmp:arp:remove')")
    @Log(title = " ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(snmpArpService.deleteSnmpArpByIds(ids));
    }
}
